package Thread;

import java.util.Scanner;

public class Demo24 {
    public static void main(String[] args) {
        Object lock = new Object();
        Thread t1 = new Thread(()->{
            try{
                Thread.sleep(1000);
                System.out.println("wait 之前");
                synchronized (lock) {
                    lock.wait();
                }
                System.out.println("wait 之后");
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        Thread t2 = new Thread(()->{
            Scanner sc = new Scanner(System.in);
            System.out.println("输入任意唤醒t1");
            sc.next();
            synchronized (lock) {
                lock.notify();
            }
        });
        t1.start();
        t2.start();
    }
}
